<%= render Admin::ContainerComponent.new do %>
  <%= render Admin::HeadingComponent.new("#{@user.name}#{t(".referrals")}") %>

  <%= render Admin::ContentComponent.new do %>
    <%= render Admin::StatContainerComponent.new do |container| %>
      <% container.with_stat title: t(".referrals_count"), value: @referrals.count, icon: "users" %>
    <% end %>
  <% end %>

  <%= render Admin::ContentComponent.new do %>
    <%= render Admin::Tables::TableComponent.new do |table| %>
      <% table.with_header t(".referred_user") %>
      <% table.with_header t(".developer") %>
      <% table.with_header t(".business") %>

      <% @referrals.each do |referral| %>
        <% table.with_row do |row| %>

          <%= row.with_cell primary: true do %>
            <%= render Admin::EmailLinkComponent.new(referral.referred_user.email) %>
          <% end %>

          <%= row.with_cell do %>
            <% if (developer = referral.referred_user.developer) %>
              <%= render Admin::LabeledAvatarComponent.new(developer, title: developer.name, path: developer_path(developer)) %>
            <% end %>
          <% end %>

          <%= row.with_cell do %>
            <% if (business = referral.referred_user.business) %>
              <%= render Admin::LabeledAvatarComponent.new(business, title: business.company, path: business_path(business), subtitle: business.name) %>
            <% end %>
          <% end %>
        <% end %>
      <% end %>
    <% end %>

    <%== pagy_nav @pagy %>
  <% end %>
<% end %>
